//
//  SUPlayer.h
//  SUMusic
//
//  Created by KevinSu on 16/1/10.
//  Copyright © 2016年 KevinSu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import "JPHomeBottomView.h"


typedef NS_ENUM(NSInteger, SUPlayStatus) {
    SUPlayStatusNon,
    SUPlayStatusLoadSongInfo,
    SUPlayStatusReadyToPlay,
    SUPlayStatusPlay,
    SUPlayStatusPause,
    SUPlayStatusStop
};

typedef NS_ENUM(NSInteger, SUMode) {
    SUModeSingle,
    SUModeOrder,
    SUModeRandom
};

@interface SUPlayerManager : NSObject <NSURLSessionDelegate> {
    
    id _timeObserve; //监控进度
}

#pragma mark - 状态
/*
 * 播放状态
 */
@property (nonatomic, assign) SUPlayStatus status;

/*
 * 播放模式
 */
@property (nonatomic, assign) SUMode mode;

#pragma mark - 列表
/*
 * 歌曲列表
 */
@property (nonatomic, strong) NSMutableArray<NSDictionary *> * songList;

/*
 * 当前播放歌曲
 */
@property (nonatomic, strong) NSDictionary * currentSong;

/*
 * 当前播放歌曲索引
 */
@property (nonatomic, assign) NSInteger currentSongIndex;

/*
 * 当前播放歌曲图片
 */
@property (nonatomic, strong) UIImage * coverImg;


#pragma mark - 播放器
/*
 * 播放器
 */
@property (nonatomic, strong) AVPlayer * player;

/*
 * 播放器播放状态
 */
@property (nonatomic, assign) BOOL isPlaying;

/*
 * 播放进度
 */
@property (nonatomic, assign) float progress;

/*
 * 缓冲进度
 */
@property (nonatomic, assign) float bufferProgress;
@property (nonatomic, assign) float saveBufferProgress;

/*
 * 当前播放时间(秒)
 */
@property (nonatomic, copy) NSString * playTime;

/*
 * 总时长(秒)
 */
@property (nonatomic, copy) NSString * playDuration;

/*
 * 当前播放时间(00:00)
 */
@property (nonatomic, copy) NSString * timeNow;

/*
 * 总时长(00:00)
 */
@property (nonatomic, copy) NSString * duration;

/*
 * 播放速率
 */
@property (nonatomic, assign) CGFloat saveRate;

/*
 * 播放定时
 */
@property (nonatomic, copy) NSString * saveClock;
/*
 * 记录倒计时剩余时间
 */
@property (nonatomic, assign) NSInteger clockLeft;
/*
 * 获取单例
 */
+ (instancetype)manager;

/*
 * 开始播放
 */
- (void)startPlay;

/*
 * 暂停播放
 */
- (void)pausePlay;


/*
 * 播放上一首
 */
- (void)playNextSong;

/*
 * 播放上一首
 */
- (void)playLastSong;


/*
 * 切歌
 */
- (void)skipSong;

// 全局视图
@property (nonatomic, strong) JPHomeBottomView *bottomView;
- (void)updateBottomView;

// 学习时长
@property (nonatomic, assign) NSInteger accumulateCount;

@property (nonatomic, strong) NSURLSessionDownloadTask *downloadTask;
@end
